Report post

What does $0 mean in Bash?

This is set at shell initialization. If Bash is invoked with a file of commands (see Section 3.8 [Shell Scripts], page 39), $0 is set to the name of that file. If Bash is started with the -c option (see Section 6.1 [Invoking Bash], page 80), then $0 is set to the first argument after the string to be executed, if one is present.

What is a $0 variable in Linux?

The $0 is one of the special variables you get in bash and is used to print the filename of the script that is currently being executed. The $0 variable can be used in two ways in Linux: Use $0 to print the name of the script that is being executed. So let's start with the first one.

What is a $0 parameter in bash scripting?

Then, the script returns The multiplication of the two given numbers is: 12 and The name of the script is: ./bash_function.sh as the output. In conclusion, the $0 parameter in bash scripting serves as a valuable tool for referencing the name of the currently executing script or shell.

Related articles

The World's Leading Crypto Trading Platform

Get my welcome gifts